﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.OpenApi.Validations;
using SmartWMS.Common.ResponseOutput;
using SmartWMS.Domain.Base;
using SmartWMS.Server.WarehouseManage.RelocationServices;
using SmartWMS.Server.WarehouseManage.RelocationServices.Dto;

namespace SmartWMS.API.Controllers.WarehouseManage
{
    /// <summary>
    /// 移库管理
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    [ApiExplorerSettings(GroupName = "Warehouse")]

    public class RelocationsController : ControllerBase
    {
        /// <summary>
        /// 移库
        /// </summary>
        public readonly IRelocationService _relocationService;
        public RelocationsController(IRelocationService relocationService)
        {
            _relocationService = relocationService;
        }
        /// <summary>
        /// 移库列表(分页)
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public Response<List<RelocationDto>> GetRelocationList(RelocationInput input)
        {
            var list = _relocationService.GetRelocationList(input);
            return list.Result;
        }
        /// <summary>
        /// 添加移库信息（实现一对多的关系）
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public Response<bool> AddRelocation(RelocationAdd input)
        {
            var list = _relocationService.AddRelocation(input);
            return list.Result;
        }
        /// <summary>
        /// 查看移库
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        [HttpPost]
        public RelocationDto GetRelocationview(ShowId Id)
        {
            var list = _relocationService.GetRelocationview(Id);
            return list.Result;
        }
        /// <summary>
        /// 查看移库列表
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        [HttpPost]
        public Response<List<RelocationDto>> GetRelocation(ShowId Id)
        {
            var list = _relocationService.GetRelocation(Id);
            return list.Result;
        }
        /// <summary>
        /// 批量删除移库管理
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        [HttpPost]
        public Response<bool> DeleteRelocationList(List<RelocationDto> dto)
        {
            var list = _relocationService.DeleteRelocationList(dto);
            return list.Result;
        }
        /// <summary>
        /// 删除移库信息
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public Response<bool> DeleteRelocation(RelocationDto input)
        {
            var list = _relocationService.DeleteRelocation(input);
            return list.Result;
        }
        /// <summary>
        /// 移库信息审核
        /// </summary>
        /// <param name="category"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        [HttpPost]
        public IActionResult UpdAteaudit(RelocationDto dto)
        {
            var list = _relocationService.UpdAteaudit(dto);
            return Ok(list.Result);
        }
        /// <summary>
        /// 移库信息审核
        /// </summary>
        /// <param name="category"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        [HttpPost]
        public Response<bool> UpdAteaudit1(RelocationDto dto)
        {
            var list = _relocationService.UpdAteaudit1(dto);
            return list.Result;
        }
        /// <summary>
        /// 反填
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        [HttpPost]
        public RelocationAdd SelRelocation(RelocationAdd dto)
        {
            var list = _relocationService.SelRelocation(dto);
            return list;
        }

        /// <summary>
        /// 修改移库信息（实现一对多的关系）
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public Response<bool> EditRelocation(RelocationAdd input)
        {
            var list = _relocationService.EditRelocation(input);
            return list.Result;
        }

        /// <summary>
        /// 显示查询选中产品数据
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public  Task<Response<List<ProductListDto>>> GetProductList(ProductLisInput input)
        {
            var result= _relocationService.GetProductList(input);
            return result;
        }
    }
}
